package jcFrame;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Paint;

import javax.swing.JLabel;
import javax.swing.JPanel;


@SuppressWarnings("serial")
public class titlePane extends JPanel{
	
	String title="myDefaultTitle";
	public void setTitle(String title){
		this.title = title;
	}
	
	jcFrame _inFrame = null;
	
	Paint _bgFrom = new GradientPaint(0, 0, new Color(180,180,180), 0, 45, new Color(150,150,150));
	Paint _bgTo = new GradientPaint(0, 45, new Color(150,150,150), 0, 50, new Color(140,140,140));
	GridBagConstraints d = new GridBagConstraints();
	Paint _shade = new Color(0,0,0,100);
	Font font =    new Font("Georgia", Font.ITALIC, 23);
	
	titlePane(jcFrame parent){
		_inFrame=parent;
		setPreferredSize(new Dimension(20,50));
		setLayout(new GridBagLayout());
		d.gridx=0;
		d.gridy=0;
		d.anchor = GridBagConstraints.NORTHWEST;
		
		add(new close(_inFrame),d);
		d.gridx=1;
		d.weightx=1;
		add(new JLabel(""),d);
		d.gridx=2;
		d.weightx=0;
		add(new maximize(_inFrame),d);
		

	    windowListener _wL = new windowListener(this);
	    addMouseListener(_wL);
	    addMouseMotionListener(_wL);
	}
	
	public void paintComponent(Graphics g){
		Graphics2D g2= (Graphics2D)g;
		g2.setPaint(_bgFrom);
		g2.fillRect(0, 0,getWidth(),45);
		g2.setPaint(_bgTo);
		g2.fillRect(0, 45,getWidth(),5);
		g2.setPaint(_shade);
		g2.setFont(font);
		g2.drawString(title, 50,35);
		g2.setPaint(Color.white);
		g2.drawString(title, 50,34);
		g2.setPaint(new Color(0,0,0,80));
		g2.drawLine(0, 0,getWidth(),0);
		g2.setPaint(new Color(255,255,255,50));
		g2.drawLine(0, 1,getWidth(),1);
	}
}